package com.woniu.humanresource.service.impl;

import com.woniu.humanresource.dao.BlacklistDao;
import com.woniu.humanresource.entity.Blacklist;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.BlacklistService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BlacklistServiceImpl implements BlacklistService {
    @Resource
    BlacklistDao blacklistDao;
    @Override
    public void insertBlacklist(Blacklist blacklist) {
        blacklistDao.insertBlacklist(blacklist);
    }

    @Override
    public PageBean<Blacklist> selectCondition(Blacklist blacklist, int pageIndex, int pageSize) {
        List<Blacklist> blacklist1 = blacklistDao.selectCondition(blacklist, pageIndex, pageSize);
        //        封装为PageBean对象，并设置属性
        PageBean<Blacklist> pageBean=new PageBean<>();
        pageBean.setBeanList(blacklist1);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectConditionCount(blacklist));
        return pageBean;
    }

    @Override
    public int selectConditionCount(Blacklist blacklist) {
        int count = blacklistDao.selectConditionCount(blacklist);
        return count;
    }

    @Override
    public void deleteBlacklist(int id) {
        blacklistDao.deleteBlacklist(id);
    }

}
